/*!
 * \file t___es_get_action.c
 *
 * \brief __es_get_action 单体测试
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * ct管理用共通函数
 *
 * \version 4.0
 * \author geyh
 * \date 2016/08/29
 *
 */


#include <CUnit/Basic.h>
#include <stdlib.h>


#include "frcomm.h"
#include "frmem.h"
#include "frbyte_buffer.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "../../../src/module/es/config.h"
#include <es/es_core.h>

#include "apmtest_cunit.h"
#include "apmtest_comm.h"

extern char * __es_get_action(Frbyte_Packet *p_st_packet);

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void case1(void)
{
    Frbyte_Packet *p_st_data = NULL;
    char *p_ret = NULL;

    p_st_data = bytebuff_creat();

    bytebuff_add(p_st_data, (char *)"\x12\x64\x69\x73\x63\x6f\x76\x65\x72\x79\x2f\x7a\x65\x6e\x2f\x6a\x6f\x69\x6e", 19);

    p_ret = __es_get_action(p_st_data);

    CU_ASSERT_STRING_EQUAL(p_ret, "discovery/zen/join");
    frfree(p_ret);

    bytebuff_free(&p_st_data);

    return;
}

static void case2(void)
{
    Frbyte_Packet *p_st_data = NULL;
    char *p_ret = NULL;

    p_ret = __es_get_action(p_st_data);

    CU_ASSERT_PTR_NULL(p_ret);

    return;
}


int add_suite___es_get_action(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __es_get_action()", __suite_init, __suite_cleanup)) == NULL)
    return FR_FAIL;

    if (CU_add_test(pSuite, "case1", case1) == NULL
            || CU_add_test(pSuite, "case2", case2) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
